﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project.MODEL;
using Project.BLL.System;

namespace Project.UI.Areas.System.Controllers
{
    public class MenusController : Controller
    {
        MenusBll bll = new MenusBll();
        // GET: System/Menus
        public ActionResult Menus()
        {
            return View();
        }

        public ActionResult GetMenusAll()
        {
            var list = bll.GetMenusAll();
            return Content(list, "Application/Json");
        }

        [HttpPost]
        public ActionResult AddMenus(Menus menu)
        {
            var data = menu.parentID == 0 ? bll.AddModular(menu) : bll.AddMenus(menu);
            return Content(data, "Application/Json");
        }

        [HttpPost]
        public ActionResult UpdateMenus(Menus menu)
        {
            return Content(bll.UpdateMenus(menu), "Application/Json");
        }

        [HttpPost]
        public ActionResult DeleteMenus(int id)
        {
            return Content(bll.DeleteByID(id), "Application/Json");
        }

        [HttpPost]
        public ActionResult UpdateMenusField(int id,string field,string value)
        {
            return Content(bll.UpdateMenus(id,field,value), "Application/Json");
        }

        [HttpPost]
        public ActionResult GetMenusAuthority(int rid)
        {
            var menus = bll.GetMenusAuthority(rid);
            return Content(menus, "Application/Json");
        }

        [HttpPost]
        public ActionResult SetMenusAuthority(int rid,int[] mids)
        {
            var menus = bll.SetMenusAuthority(rid, mids);
            return Content(menus, "Application/Json");
        }

    }
}